﻿CREATE PROCEDURE [dbo].[proc_Users_GetList]
	(
	@CompanyId int,
	@Stext nvarchar(50),
	@StartIndex int,
	@EndIndex int
	)
	
AS
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY UserId) AS Row,
	UserId,
	UserName,
	Password,
	RTX,
	Email,
	CompanyId,
	[Name],
	CreateDate,
	IsLockout,
	ISNULL(LastLoginDate,'1900-01-01') As LastLoginDate,
	FailedPasswordAttemptCount
	From aspnet_Users Where (@CompanyId=0 Or CompanyId=@CompanyId) And (@Stext IS NULL Or [Name] like '%'+@Stext+'%')
	)
	
	Select * From list Where Row between @StartIndex and @EndIndex
	RETURN
